﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using PraxisRent.BL;
using PraxisRent.Entities;
using Microsoft.Practices.Unity;

namespace PraxisRent.UI
{
    public partial class FrmDescripcionPago : Form
    {
        public FrmDescripcionPago()
        {
            InitializeComponent();
            this.BuilUp();
        }

        private void FrmDescripcionPago_Load(object sender, EventArgs e)
        {
            pAGOBindingSource.AddNew();
        }

        public PAGO currentPago { get; set; }

        private void btnOk_Click(object sender, EventArgs e)
        {
            currentPago = pAGOBindingSource.Current as PAGO;
            this.Close();
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void descripcionTextBox_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (Char.IsLetter(e.KeyChar))
            {
                e.Handled = false;
            }
            else if (Char.IsControl(e.KeyChar))
            {
                e.Handled = false;
            }
            else if (Char.IsSeparator(e.KeyChar))
            {
                e.Handled = false;
            }
            else
            {
                e.Handled = true;
            }
        }

        private void numComprobanteTextBox_KeyPress(object sender, KeyPressEventArgs e)
        {
            var punto = Convert.ToString(".");
            var guion = Convert.ToString("-");


            string cadena = punto + guion;

            if (Char.IsLetter(e.KeyChar) || cadena.Contains(e.KeyChar) || char.IsNumber(e.KeyChar))
            {
                e.Handled = false;
            }
            else if (Char.IsControl(e.KeyChar))
            {
                e.Handled = false;
            }
            else if (Char.IsSeparator(e.KeyChar))
            {
                e.Handled = false;
            }
            else
            {
                e.Handled = true;
            }
        }
    }
}
